//
//  GWTopicVoiceView.m
//  百思不得姐
//
//  Created by qianfeng on 16/3/7.
//  Copyright © 2016年 高炜. All rights reserved.
//

#import "GWTopicVoiceView.h"
#import <UIImageView+WebCache.h>
#import "GWTopicModel.h"
#import "GWTopicPictureView.h"
@interface GWTopicVoiceView ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UILabel *playCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *voiceTimeLabel;

@end
@implementation GWTopicVoiceView
-(void)awakeFromNib
{
    self.autoresizingMask =UIViewAutoresizingNone;
    [self addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(pushPictureView)]];
}
-(void)pushPictureView
{
    GWTopicPictureView *picView= [[GWTopicPictureView alloc]init];
    
    [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:picView animated:YES completion:nil];
    picView.topic =self.topic;
    
}
+(instancetype)topicVoiceView
{
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil]lastObject];
}

-(void)setTopic:(GWTopicModel *)topic
{
    _topic =topic;
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:topic.largeImage]];
    
    self.playCountLabel.text =[NSString stringWithFormat:@"%ld播放",topic.playcount];
    NSInteger minitue =topic.voicetime /60;
    NSInteger sencond =topic.voicetime%60;
    self.voiceTimeLabel.text =[NSString stringWithFormat:@"%02ld:%02ld",minitue,sencond];
}

@end
